package com.lengxf.mybatis.mysql.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lengxf.mybatis.mysql.entity.Book;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Set;

@Mapper
public interface TableMapper {

    @Update("""
    <script>
        CREATE TABLE ${tableName} (
            <foreach collection="list" item="item"  separator=",">
                    ${item}
            </foreach>
            , PRIMARY KEY (`id`)
        ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT=${tableComment};
    </script>
    """)
    void generateTable(@Param("tableName") String tableName ,@Param("tableComment") String tableComment , @Param("list") List<String> columnSql);

    @Update("""
        DROP TABLES if EXISTS ${tableName};
    """)
    void dropTable(@Param("tableName") String tableName);
}
